package cn.tedu.sp04.order.feign;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ItemClientFB implements ItemClient{
    @Override
    public JsonResult<List<Item>> getItems(String orderId) {
        //模拟有Redis 缓存数据
        if (Math.random()<0.5){
            //50%概率返回模拟缓存数据
            List<Item> list = new ArrayList<>();
            list.add(new Item(1,"缓存商品1",1));
            list.add(new Item(1,"缓存商品1",1));
            list.add(new Item(1,"缓存商品1",1));
            list.add(new Item(1,"缓存商品1",1));
            list.add(new Item(1,"缓存商品1",1));
        }
        return JsonResult.err().msg("调用商品服务失败");
    }

    @Override
    public JsonResult<?> decreaseNumber(List<Item> items) {
        return JsonResult.err().msg("调用商品服务失败");
    }
}
